package com.orhon.smartcampus.modules.student.mm;

import java.util.List;

import org.mapstruct.InheritConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;

import com.orhon.smartcampus.modules.base.gqlModel.GQLDictionary;
import com.orhon.smartcampus.modules.base.mm.DictionaryMapper;
import com.orhon.smartcampus.modules.base.mm.LangMapper;
import com.orhon.smartcampus.modules.base.mm.RegionMapper;
import com.orhon.smartcampus.modules.student.entity.Learninfo;
import com.orhon.smartcampus.modules.student.gqlModel.GQLStudentLearnInfo;

@Mapper(
        uses = {
                LangMapper.class,
                RegionMapper.class,
                DictionaryMapper.class
        }
)
public interface LearninfoMapper {

    LearninfoMapper MAPPER = Mappers.getMapper(LearninfoMapper.class);
    
    @Mapping(source = "id" , target = "id")
    @Mapping(source = "atSchool" , target = "at_school")
    @Mapping(source = "membershipNumber" , target = "membership_number")
    @Mapping(source = "classCode" , target = "class_code")
    @Mapping(source = "startYear" , target = "start_year")
    @Mapping(source = "finishedYear" , target = "finished_year")
    @Mapping(source = "wayToStudy" , target = "way_to_study")
    @Mapping(source = "wayToAnnex" , target = "way_to_annex")
    @Mapping(source = "confirmed" , target = "confirmed")
    @Mapping(source = "confirmedBy" , target = "confirmed_by")
    @Mapping(source = "transactionType" , target = "transaction_type",qualifiedByName = "str2dic")//数据字典
    @Mapping(source = "admissionMethod" , target = "admission_method",qualifiedByName = "str2dic")//数据字典
    @Mapping(source = "studentFrom" , target = "student_from",qualifiedByName = "str2dic")//数据字典
    @Mapping(ignore = true, target = "user" )
    @Mapping(ignore = true, target = "student" )
    @Mapping(ignore = true, target = "school" )
    @Mapping(ignore = true, target = "arrive" )
    @Mapping(ignore = true, target = "eclass" )
    GQLStudentLearnInfo toLearninfo(Learninfo entity);
    
    @InheritConfiguration(name = "toLearninfo")
    List<GQLStudentLearnInfo> toLearninfoList(List<Learninfo> entities);
    
    @Named("dictionary")
    default GQLDictionary convertDictionary(Integer pid){
        return new GQLDictionary();
    }


}
